﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DiveManager
{
    public partial class KompressorMain : Form
    {
        protected DiveDatabaseEntities diveDatabase;
        protected BindingSource bindingSource;
        
        public KompressorMain()
        {
            InitializeComponent();

            // Init Database
            diveDatabase = new DiveDatabaseEntities();
            bindingSource = new BindingSource();
        }

        private void btKompressorReport_Click(object sender, EventArgs e)
        {
            //Öffnen von KompressorReport
        }

        private void btWartungsbuch_Click(object sender, EventArgs e)
        {
            //Öffnen des Wartungsbuches
        }

        private void btAuswertungen_Click(object sender, EventArgs e)
        {
            //Öffnen der Auswertungsauswahl
        }

        private void KompressorMain_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        protected void LoadData()
        {
            IQueryable<KompressorReport> dataQuery = (from a in diveDatabase.KompressorReport
                                                   select a);
            // Bind Data to BindingSource
            bindingSource.DataSource = dataQuery;
            // Bind BindingSource to List
            KompressorList.DataSource = bindingSource;
            // Hide ID-Columns
            KompressorList.Columns["ID"].Visible = false;
            KompressorList.Columns["Vorgang"].Visible = true;
            KompressorList.Columns["Fuellnummer"].Visible = true;
            KompressorList.Columns["Wartungsnummer"].Visible = true;
            KompressorList.Columns["Date"].Visible = true;
            KompressorList.Columns["User"].Visible = false;
            // Set Column Headers
            KompressorList.Columns["Fuellnummer"].HeaderText = "Füll Nr.";
            KompressorList.Columns["Wartungsnummer"].HeaderText = "Wartung";
            KompressorList.Columns["Date"].HeaderText = "Auftreten";
        }
    }
}
